package com.zheng.flower接口版;

import java.util.Scanner;

public class newFilwerIndex {
    public static final Scanner INPOT=new Scanner(System.in);
    public static final FilwerOder[] filwerList=new FilwerOder[10];
    public static final FilwerServiceImpl filwerImpl=new FilwerServiceImpl();
    static {
        filwerList[0]=new FilwerOder("1001","香槟玫瑰",10,318.0,"2016-12-12","张三","");
        filwerList[1]=new FilwerOder("1002","白玫瑰",99,538.0,"2016-12-20","李四","");
        filwerList[2]=new FilwerOder("1003","紫色桔梗",40,148.0,"2016-12-24","张三","立刻入睡。。。");
        filwerList[4]=new FilwerOder("1005","无声的爱",1000,219.0,"2016-12-18","李四","做西格玛男人。。。");
        filwerList[3]=new FilwerOder("1004","粉香百合",120,188.0,"2016-12-26","张三","这朵玫瑰我送给我妈。。。");
    }
    public static void main(String[] args) {
        out:
        while (true){
            filwershow();
            int oder=INPOT.nextInt();
            switch(oder){
                case 1:
                    //打印菜单
                    filwerImpl.FilwerOderShow();
                    break;
                case 2:
                    //修改订单
                    filwerImpl.Update();
                    break;
                case 3:
                    //删除订单
                    filwerImpl.delete();
                    break;
                default:
                    System.out.println("系统退出");
                    break out;
            }


        }
    }
    /*
    //删除订单
    public static void delete() {
        System.out.println("请输入你要删除的编号");
        String inpor=INPOT.next();
        boolean bl=true;
        int uid=-1;
        for (int i = 0; i < filwerList.length; i++) {
            if (filwerList[i]!=null){
                if (filwerList[i].getId().equals(inpor)){
                    bl=false;
                    uid=i;
                    break;
                }
            }
        }
        if (bl){
            System.out.println("对不起，你要修改的订单不存在！");
            return;
        }
        System.out.println("编号\t鲜花名称\t销售数量\t价格\t销售日期\t销售员\t备注");
        System.out.println(filwerList[uid].getId()+"\t"+filwerList[uid].getName()+"\t"+filwerList[uid].getCount()+
                "\t"+filwerList[uid].getPrice()+"\t"+filwerList[uid].getDate()+"\t"+filwerList[uid].getStaff()+"\t"
                +filwerList[uid].getBeiZu());
        System.out.println("确定要删除吗？（y/n）");
        String str=INPOT.next();
        if (str.equals("y")){
            filwerList[uid]=null;
            System.out.println("删除成功！");
            FilwerOderShow();
        }else {
            System.out.println("删除失败！");
        }
    }
    //修改销售订单
    public static void Update(){
        System.out.println("请输入你要修改的编号");
        String inpor=INPOT.next();
        boolean bl=true;
        FilwerOder uid=null;
        for (FilwerOder fo : filwerList) {
            if (fo!=null){
                if (fo.getId().equals(inpor)){
                    bl=false;
                    uid=fo;
                    break;
                }
            }

        }
        if (bl){
            System.out.println("对不起，你要修改的订单不存在！");
            return;
        }
        System.out.println("编号\t鲜花名称\t销售数量\t价格\t销售日期\t销售员\t备注");
        System.out.println(uid.getId()+"\t"+uid.getName()+"\t"+uid.getCount()+
                        "\t"+uid.getPrice()+"\t"+uid.getDate()+"\t"+uid.getStaff()+"\t"
                        +uid.getBeiZu());
        System.out.println("请输入修改后的鲜花名称");
        String newname=INPOT.next();
        System.out.println("请输入修改后的销售数量");
        int newcount=INPOT.nextInt();
        System.out.println("请输入修改后的鲜花价格");
        double newprice=INPOT.nextDouble();
        System.out.println("请输入修改后的日期");
        String newdate=INPOT.next();
        System.out.println("请输入修改后的销售员");
        String newstaff=INPOT.next();
        System.out.println("请输入修改后的备注");
        String newbeizu=INPOT.next();
        System.out.println("你确定要修改吗？（y/n）");
        String quereng=INPOT.next();
        if ("y".equals(quereng)){
            uid.setName(newname);
            uid.setCount(newcount);
            uid.setPrice(newprice);
            uid.setDate(newdate);
            uid.setStaff(newstaff);
            uid.setBeiZu(newbeizu);
            FilwerOderShow();
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
            return;
        }


    }
    //查询销售订单
    public static void FilwerOderShow(){
        System.out.println("编号\t鲜花名称\t销售数量\t价格\t销售日期\t销售员\t备注");
        for (FilwerOder fo : filwerList) {
            if (fo!=null){
                System.out.println(fo.getId()+"\t"+fo.getName()+"\t"+fo.getCount()+
                        "\t"+fo.getPrice()+"\t"+fo.getDate()+"\t"+fo.getStaff()+"\t"
                        +fo.getBeiZu());
            }
        }
    }

     */
    //菜单打印
    private static void filwershow() {
        System.out.println("====================欢迎光临”七彩鲜花“销售管理系统======================");
        System.out.println("1.查询销售订单");
        System.out.println("2.修改销售订单");
        System.out.println("3.删除销售订单");
        System.out.println("4.系统退出");
        System.out.println("====================欢迎光临”七彩鲜花“销售管理系统======================");
    }
}
